<template>
<div class="wrap">
 <div class="login-form">
        <div class="top-login">
            <span><img src="@/assets/group.png" alt=""/></span>
        </div>
        <h1>Login</h1>
        <div class="login-top">
            <el-form id="form" :model="loginForm">
                <div class="login-ic">
                    <i ></i>
                    <input type="text" name="account" v-model="loginForm.account"/>
                    <div class="clear"> </div>
                </div>
                <div class="login-ic">
                    <i class="icon"></i>
                    <input type="password" name="password" v-model="loginForm.password"/>
                    <div class="clear"> </div>
                </div>
                <span style="color: #1b75bb"></span>
                <div class="log-bwn">
                    <el-button type="danger" style="width:460px !important;" @click="doLogin()">登录后台</el-button>
                </div>
            </el-form>
        </div>
    </div>
</div>
</template>

<script>
export default {
  name: 'Login',
  components:{
  },
data() {
  return {
      loginForm:{}
  }
},
methods:{
 doLogin() {
      if (!this.loginForm.account) {
        this.$message.error("请输入账号！");
        return;
      } else if (!this.loginForm.password) {
        this.$message.error("请输入密码！");
        return;
      } else {
        //校验用户名和密码是否正确;
        // this.$router.push({ path: "/personal" })
        this.$store.dispatch('Login', this.loginForm).then(() => {
            this.$router.push({ path: '/home' })
          }).catch((err) => {
            console.log(err)
          })
      }
    }
}
}
</script>

<style scoped>
@import '~@/styles/w3clogin.css';
</style>